//
//  AwardCell.m
//  JiCaiBao
//
//  Created by rgx on 16/11/7.
//  Copyright © 2016年 rgx. All rights reserved.
//

#import "AwardCell.h"
#import "awardData.h"

@implementation AwardCell

- (void)awakeFromNib {
    // Initialization code
    
    self.ballArr = [NSMutableArray arrayWithObjects:self.ball1,self.ball2,self.ball3,self.ball4,self.ball5,self.ball6,self.ball7,self.ball8, nil];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)flashCell :(awardData *)data :(int)index{
    if (index == 0) {
        self.gameId.text = @"双色球";
        [self.ball7 setBackgroundImage:[UIImage imageNamed:@"background_selected_blue"] forState:UIControlStateNormal];
        self.ball8.hidden = YES;
        if (data.prizeBalls) {
            NSArray *redBalls = [data.prizeBalls objectForKey:@"red"];
            NSArray *blueBall = [data.prizeBalls objectForKey:@"blue"];
            for (int i = 0; i < redBalls.count; i++) {
                [(UIButton *)[self.ballArr objectAtIndex:i] setTitle:[NSString stringWithFormat:@"%@",[redBalls objectAtIndex:i]] forState:UIControlStateNormal];
            }
            if (blueBall.count) {
                [self.ball7 setTitle:[NSString stringWithFormat:@"%@",[blueBall objectAtIndex:0]] forState:UIControlStateNormal];
            }
        }
    }else if (index == 1){
        self.gameId.text = @"快3";
        self.ball4.hidden = YES;
        self.ball5.hidden = YES;
        self.ball6.hidden = YES;
        self.ball7.hidden = YES;
        self.ball8.hidden = YES;
        if (data.prizeBalls) {
            NSArray *redBalls = [data.prizeBalls objectForKey:@"red"];
            for (int i = 0; i < redBalls.count; i++) {
                [(UIButton *)[self.ballArr objectAtIndex:i] setTitle:[NSString stringWithFormat:@"%@",[redBalls objectAtIndex:i]] forState:UIControlStateNormal];
            }
        }

    }else if (index == 2){
        self.gameId.text = @"福彩3D";
        self.ball4.hidden = YES;
        self.ball5.hidden = YES;
        self.ball6.hidden = YES;
        self.ball7.hidden = YES;
        self.ball8.hidden = YES;
        if (data.prizeBalls) {
            NSArray *redBalls = [data.prizeBalls objectForKey:@"red"];
            for (int i = 0; i < redBalls.count; i++) {
                [(UIButton *)[self.ballArr objectAtIndex:i] setTitle:[NSString stringWithFormat:@"%@",[redBalls objectAtIndex:i]] forState:UIControlStateNormal];
            }
        }
        
    }else if (index == 3){
        self.gameId.text = @"七乐彩";
        
        if (data.prizeBalls) {
            NSArray *redBalls = [data.prizeBalls objectForKey:@"red"];
            NSArray *blueBall = [data.prizeBalls objectForKey:@"blue"];
            for (int i = 0; i < redBalls.count; i++) {
                [(UIButton *)[self.ballArr objectAtIndex:i] setTitle:[NSString stringWithFormat:@"%@",[redBalls objectAtIndex:i]] forState:UIControlStateNormal];
            }
            [self.ball8 setTitle:[NSString stringWithFormat:@"%@",[blueBall objectAtIndex:0]] forState:UIControlStateNormal];
        }
        
    }
    if (data.lotteryIssue || data.lotteryTime) {
        
        self.gameDes.text = [NSString stringWithFormat:@"第 %@ 期  %@",data.lotteryIssue,data.lotteryTime];
    }
    
}
- (void)flashCell1:(NSString *)gameId :(int)row{
    
    if (row > 0) {
        for (UIButton *ball in self.ballArr) {
            [ball setBackgroundImage:nil forState:UIControlStateNormal];
            [ball setTitleColor:ColorWithRGB(233, 66, 66) forState:UIControlStateNormal];
            if ([gameId isEqualToString:lottery_ssq_id]) {
                if (ball.tag == 7) {
                    [ball setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
                }
            }else if ([gameId isEqualToString:lottery_qlc_id]){
                if (ball.tag == 8) {
                    [ball setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
                }
            }else if([gameId isEqualToString:lottery_hbk3_id]){
                [ball setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                
            }
        }
        
    }
}
@end
